{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-09-11T08:01:37.611878Z",
     "start_time": "2025-09-11T08:01:37.609008Z"
    }
   },
   "source": [
    "# 异常处理\n",
    "# try:\n",
    "#     s = input('please enter two numbers separated by comma: ')\n",
    "#     num1 = int(s.split(',')[0].strip())\n",
    "#     num2 = int(s.split(',')[1].strip())\n",
    "# except (ValueError, IndexError) as err:\n",
    "#     print('Value Error: {}'.format(err))\n",
    "#     print('continue')\n",
    "import sys\n",
    "try:\n",
    "    f = open('in.txt', 'r')\n",
    "except OSError as err:\n",
    "    print('OS error: {}'.format(err))\n",
    "except:\n",
    "    print('Unexpected error:', sys.exc_info()[0])\n",
    "finally:\n",
    "    f.close()"
   ],
   "outputs": [],
   "execution_count": 6
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
